Remove auto-execution on Flash in the event of a 429/Quota failover - #3662
Conversation
…aging for quotas and Flash failover
…aging for quotas and Flash failover
There was a problem hiding this comment.
Summary of Changes
Hello @bdmorgan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses a user experience issue where hitting a quota limit on a 'Pro' model would automatically trigger a fallback to the 'Flash' model and attempt to continue the current query, causing confusion. The changes introduce more granular error detection for quota limits, provide clearer user messages, and, crucially, prevent the automatic continuation of queries with the Flash model after a quota-induced fallback, requiring explicit user action to proceed.
Highlights
- Prevented Automatic Flash Execution: When a 'Pro' model (e.g.,
gemini-2.5-pro) hits a quota limit, the system now explicitly stops the current execution and requires the user to initiate a new query for the 'Flash' model. Previously, it would automatically attempt to continue the current query with the Flash model, leading to user confusion. - Granular Quota Error Detection: Introduced new utility functions (
isProQuotaExceededError,isGenericQuotaExceededError) to differentiate between various 429 (Too Many Requests) errors, specifically identifying Pro model quota limits versus general rate limits or other quota issues. - Enhanced User Feedback: Updated API error parsing to provide more specific and actionable messages to users when quota limits are reached. Messages now include details about the specific model that hit the quota, and guidance on upgrading or switching authentication methods, tailored to the user's current tier (Free, Standard, Legacy).
- Controlled Model Fallback Logic: Modified the
flashFallbackHandlerandretryWithBackoffmechanisms to pass detailed error information. The handler can now explicitly prevent immediate retry/continuation of the current query after a quota-based model switch, giving the user control. - State Management for Quota Errors: Added new state variables and config flags (
modelSwitchedFromQuotaError,quotaErrorOccurred) to track when a model switch occurs due to a quota error. This ensures that subsequent Flash model calls are blocked until a new user query is explicitly submitted, and these flags are reset upon a new query.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request is a significant improvement to the user experience when handling API quota limits. I appreciate the clear description of the new workflow and the thoroughness of the changes, including the new error detection logic and extensive tests.
I've found one area with a logical issue that I've detailed below. Addressing this will make the implementation more robust and easier to maintain.
Once again, great work on this feature. I'm looking forward to seeing these changes merged.
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x' artifact from the main CI run. |
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-20.x' artifact from the main CI run. |
|
Related to this issue as well: #2613 |
|
When will this get released for npm? Ah, sorry. Was looking at a specific version URL, there, not noticing the updates. So nevermind. |
…oogle-gemini#3662) Co-authored-by: Jenna Inouye <jinouye@google.com>
…oogle-gemini#3662) Co-authored-by: Jenna Inouye <jinouye@google.com>
…oogle-gemini#3662) Co-authored-by: Jenna Inouye <jinouye@google.com>
User Experience Now
Before Fix:
After Fix:
📋 User Workflow
The solution respects quota limits, gives users full control, and prevents unwanted Flash execution exactly as requested!
Resolves #2711